<?php
// 应用公共文件
use app\model\User;
use think\facade\Db;

if(!function_exists('getSalt')){
    function getSalt(){
        return 'e5F21037632b2Cdee1af89#!f9a76E89';
    }
}

if(!function_exists('getSha1Password')){
    function getSha1Password($password){
        return sha1($password.getSalt());
    }
}

if(!function_exists('userExist')){
    function userExist($value,$field='phone'){
       $user = User::where($field,$value)->findOrEmpty();
       return !$user->isEmpty();
    }
}

if(!function_exists('isSuperAdmin')){
    function isSuperAdmin($user_id){
        $user = Db::name('user')->order('id', 'asc')->find();
        return $user_id == $user['id'];
    }
}
















